import 'package:logger/logger.dart';
import 'package:lib_util/log/log.dart';
import 'network.dart';

class Config {
  static Logger logger = Log.logger;

  static const int balanceFixedNum = 8;
  static const int balanceFixedNumUsingFiat = 2;
  static const int marketFixedNum = 2;
  static const int gasFeeFixedNum = 18;
  static const int priceNum = 4;

  static const int maxStoreTransactionCountForSingleToken = 100;

  static const int tronChainId = 184346700239; //真实应该是这个728126428
  static const String tronApiKey = 'f322695a-5963-4910-87d5-ff2878ac0d63';

  static final Map<Chain, String> supportNFT721TransferChains = {
    ChainList.ethChain: "0xB5d4D4308bD28e3938Eb0Cc18C141Ab41C198581",
    ChainList.bscChain: "0xB5d4D4308bD28e3938Eb0Cc18C141Ab41C198581",
    ChainList.polygonChain: "0xB5d4D4308bD28e3938Eb0Cc18C141Ab41C198581",
    ChainList.ompChain: "0x95751FFE002Ac37e0be04777965D157852501D67"
  };

  // CHAINiD 对应 的 USDT 合约地址  根据网络 添加能修改的usdt
  static Map<String, String> getChainUSDTContract = {
    "1": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "56": "0x55d398326f99059ff775485246999027b3197955",
    //----------------- 测试地址 USDT-------------------
    "97": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
    "137": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
    "3448148188": "TD9L79zdi9NDHawra7EprnuiRhoLEQUi6p"
  };

  static List<String> staticContainChainId=[
    "1","5","56","97","204","137","43114","42161","10","250"
  ];
  // 获取 网络id  对应 的 rpc 地址
  static Map<String, List<String>> staticRPCChain = {
    "1": [
      "https://rpc.ankr.com/eth/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
      "https://radial-damp-mound.quiknode.pro/db23822ae707fd3930e278d95afdcc92fd805e31",
      "https://ethereum.blockpi.network/v1/rpc/fb678ede8b7a1c6f44f458fa0e307a410eb7fe52",
    ],
    "5": [
      "https://ethereum-goerli.publicnode.com",
    ],
    "56": [
      "https://cool-newest-sunset.bsc.quiknode.pro/a9fb9e8f56e3c5ff0f575c150607dc375bf5c8ef",
      "https://cool-newest-sunset.bsc.quiknode.pro/a9fb9e8f56e3c5ff0f575c150607dc375bf5c8ef",
      "https://bsc.blockpi.network/v1/rpc/f1f1595a7988e6c9f153b81882efe04b6d0d4a72",
    ],
    "97": [
      "https://bsc-testnet.publicnode.com"
    ],
    "204": [
      "https://opbnb-mainnet-rpc.bnbchain.org",
      "https://opbnb-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3",
      "https://opbnb-mainnet.nodereal.io/v1/e9a36765eb8a40b9bd12e680a1fd2bc5"
    ],
    "137": [
      "https://rpc.ankr.com/polygon/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
      "https://long-cosmopolitan-needle.matic.quiknode.pro/9a761a246c1a60334f22d72632b27e1ef2102558",
      "https://polygon.blockpi.network/v1/rpc/ca95957e5b90056f55a57ba3785488b664c56fe0"
    ],
    "43114": [
      "https://rpc.ankr.com/avalanche/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
      "https://holy-icy-butterfly.avalanche-mainnet.quiknode.pro/a30299a29e9b89a4ff0f227d3f8e9b12c48813a1/ext/bc/C/rpc",
      "https://avalanche.blockpi.network/v1/rpc/eb9cb1c79b89f6f42eeed746fa33a9acb822273e",
    ],
    "42161": [
      "https://rpc.ankr.com/arbitrum/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
      "https://frequent-quiet-scion.arbitrum-mainnet.quiknode.pro/4f69ab1cc00825a0806edb96b484cc334119d10f",
      "https://arbitrum.blockpi.network/v1/rpc/ac8b853833bd8dca823951d00687672cf0b09e99"
    ],
    "10": [
      "https://rpc.ankr.com/optimism/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
      "https://responsive-wispy-orb.optimism.quiknode.pro/71a219025181309186b20dec6d40b05f5da4adb6",
      "https://optimism.blockpi.network/v1/rpc/b2555a5ff2db60784ab0d4673db6f1b791365eb5"
    ],
    "250": [
      "https://fantom.blockpi.network/v1/rpc/96b0aabf00d0702134ff6a92724f8a79ccc9574f",
      "https://rpc.ankr.com/fantom/e5120d373f676844612d9a719fc0a249b74359a6c7717c6695ea6a8d7bbace63",
    ]
  };

  //  ETHEREUM = 1,
  //   GOERLI = 5,
  //   BSC = 56,
  //   BSC_TESTNET = 97,
  //   ZKSYNC_TESTNET = 280,
  //   ZKSYNC = 324,
  //   OPBNB_TESTNET = 5611,
  //   OPBNB = 204,
  //   POLYGON_ZKEVM = 1101,
  //   POLYGON_ZKEVM_TESTNET = 1442,
  //   ARBITRUM_ONE = 42161,
  //   ARBITRUM_GOERLI = 421613,
  //   SCROLL_SEPOLIA = 534351,
  //   LINEA = 59144,
  //   LINEA_TESTNET = 59140,
  //   BASE = 8453,
  //   BASE_TESTNET = 84531,
  static const Map<String, String> defiLlamaChainNames = {
    "56": 'bsc',
    "1": 'ethereum',
    "5": '',
    "97": '',
    "42161": 'arbitrum',
    "421613": '',
    "1101": 'polygon_zkevm',
    "1442": '',
    "324": 'era',
    "280": '',
    "59140": '',
    "84531": '',
    "204": 'op_bnb',
    "5611": '',
    "534351": '',
    "59144": 'linea',
    "8453": 'base',
  };

  static const String customChainShortNamePrefix = 'custom_w51CFZm8GGD4h2lc_'; //避免chain short name重复，自定义添加的链加上此前缀

  static final Map<Chain, String> usdtContracts = {
    ChainList.ompChain: "0x437635BA437728c577f4234F3A3F48619f02d75c",
    ChainList.bscChain: "0x55d398326f99059fF775485246999027B3197955",
    ChainList.tronChain: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
  };

  static final Map<Chain, String> anySwapContracts = {
    ChainList.ompChain: "0x8f5D0230d015b5a55B6a3B34AAd9400BDA5163E8",
    ChainList.bscChain: "0x241C019A3f2673F5B584Dcf9513EBC8b44F5db3F"
  };

  static final Map<Chain, String> anySwapDataContracts = {
    ChainList.ompChain: "0xB3729348a08D551B9b4A38C7e222594A98A571a5",
    ChainList.bscChain: "0x012F1F355b68A787d19b6eD615C43A3149b8408A"
  };

  static final Map<Chain, String> ompBridgeContracts = {
    ChainList.ompChain: "0xfc29A22D5BB673F3205873d7E81d322bbD678d75",
    ChainList.tronChain: "THXTb1jSDD7bu2qeqA56hiAXx4qQPfAhvZ"
  };

  static const bool dexEnvProduct = true;

  static final Map<Chain, String> omxContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0xD9d48DB5C3589B8c369b8e06110B7477d174B227" : "0x33604D9F834fcDa0c1adA84F29bcA11882C6831c",
  };

  static final Map<Chain, String> miningNodePoolContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0x052D75C7e406E3CF4D3cae70bF4D83BB0648Df9f" : "0x87B95798e1C4a432142321eF76263298a9a8E956"
  };

  static final Map<Chain, String> dexContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0x7D2C06fd3ba83fE40C427BEB6251bC9CAB0FaC15" : "0x8ddE6F84ebe5138811c4347a5A072aC89682F91c"
  };
  static final Map<Chain, String> dexDelegateContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0xeA5fE1db56a9a24a22D181C4DF4Ce61E18B223Ef" : "0xd6DaF6F057Bd1F2d78DA2c635E6938255a7717e6"
  };
  static final Map<Chain, String> miningContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0xEF3C5cC3d26932feABa95f9388De2036B64613eA" : "0x0325905a6f3cC73479357db076292DB80AA43981"
  };
  static final Map<Chain, String> invitersContracts = {
    ChainList.ompChain:
        dexEnvProduct ? "0x117E63a56c2DADCA1cE79DF18138Ac0473647000" : "0xD8412893d465a4De20692D461EB4c1E3b54f2608"
  };
}
